package introse;

public class mainWindow extends javax.swing.JFrame {

    public mainWindow() {
        initComponents();
        setLocationRelativeTo(null);
    }

    public void setIndex(int tabIndex) {
        mainTabs.setSelectedIndex(tabIndex);
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        mainTabs = new javax.swing.JTabbedPane();
        transactionView = new introse.transactionViewer();
        sourceView = new introse.sourceViewer();
        clientView = new introse.clientViewer();
        productView = new introse.productViewer();
        header = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Gasul Marketing");
        setResizable(false);

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/introse/images/Sashmir Gasul Marketing Small.png"))); // NOI18N

        mainTabs.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                mainTabsStateChanged(evt);
            }
        });
        mainTabs.addTab("Transaction", new javax.swing.ImageIcon(getClass().getResource("/introse/images/Transaction Small.png")), transactionView); // NOI18N

        sourceView.setFocusable(false);
        mainTabs.addTab("Source", new javax.swing.ImageIcon(getClass().getResource("/introse/images/Inventory Small.png")), sourceView); // NOI18N
        mainTabs.addTab("Client", new javax.swing.ImageIcon(getClass().getResource("/introse/images/Client Small.png")), clientView); // NOI18N
        mainTabs.addTab("Product", new javax.swing.ImageIcon(getClass().getResource("/introse/images/Product Small.png")), productView); // NOI18N

        header.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
        header.setText("Gasul Marketing");
        header.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(header)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addComponent(mainTabs, javax.swing.GroupLayout.DEFAULT_SIZE, 1251, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(4, 4, 4)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addComponent(header))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(mainTabs, javax.swing.GroupLayout.DEFAULT_SIZE, 639, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void mainTabsStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_mainTabsStateChanged
        switch (mainTabs.getSelectedIndex()) {
            case 0:
                header.setText("Transaction");
                header.setIcon(new javax.swing.ImageIcon(getClass().getResource("/introse/images/Transaction Small.png")));
                transactionView.loadTransactionTable();
                break;
            case 1:
                header.setText("Source");
                header.setIcon(new javax.swing.ImageIcon(getClass().getResource("/introse/images/Inventory Small.png")));
                sourceView.loadSourceTable();
                break;
            case 2:
                header.setText("Client");
                header.setIcon(new javax.swing.ImageIcon(getClass().getResource("/introse/images/Client Small.png")));
                clientView.loadClientTable();
                break;
            case 3:
                header.setText("Product");
                header.setIcon(new javax.swing.ImageIcon(getClass().getResource("/introse/images/Product Small.png")));
                productView.loadProductsTable();
                break;
        }
    }//GEN-LAST:event_mainTabsStateChanged

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(mainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(mainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(mainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(mainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new mainWindow().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private introse.clientViewer clientView;
    private javax.swing.JLabel header;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JTabbedPane mainTabs;
    private introse.productViewer productView;
    private introse.sourceViewer sourceView;
    private introse.transactionViewer transactionView;
    // End of variables declaration//GEN-END:variables
}
